<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>代码生成</title>
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <link rel="stylesheet" href="/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <script src="../../../static/js/pdfjs-4.1.392/build/pdf.mjs"></script>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <!-- 表格 -->
        <table class="layui-hide" id="table-generator-table" lay-filter="table-generator-table"></table>
    </div>
</div>
<!--表格头部工具类（左上）-->
<script type="text/html" id="toolbar-table-table">
    <div class="layui-btn-container">
        <!-- 【刷新】-->
        <button class="layui-btn layui-btn-sm layuimini-btn-primary" lay-event="btn-requestLog-refresh"><i
                class="fa fa-refresh"></i></button>
    </div>

</script>
<!--表格每行末尾的操作按钮-->
<script type="text/html" id="tool-table-table">
    <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="table-details"><i class="fa fa-eye"></i> 详情</a>
    <a class="layui-btn layui-btn-xs layuimini-btn-primary" lay-event="table-del"><i class="fa fa-delete"></i> 删除</a>
</script>
<!-- 点击行末【生成代码】后的弹窗内容 -->
<div id="dom_generator" style="display: none;">
    <form class="layui-form layui-form-pane" action="">
        <!-- 【项目包路径】 -->
        <div class="layui-form-item">
            <label class="layui-form-label">项目路径<span style="color:red"> *</span></label>
            <div class="layui-input-inline" style="width: 275px">
                <input type="text" value="/src/main/java/com/zxdmy/excite/" name="projectPack" lay-verify="projectPack"
                       placeholder="请输入项目路径" autocomplete="off"
                       class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">相对路径，从/src开始</div>
        </div>
        <!-- 【模块名称】 -->
        <div class="layui-form-item">
            <label class="layui-form-label">模块名称<span style="color:red"> *</span></label>
            <div class="layui-input-inline" style="width: 275px">
                <input type="text" value="system" name="moduleName" lay-verify="moduleName" placeholder="请输入模块名称"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">多模块开发中的模块名称</div>
        </div>
        <!-- 父包名 -->
        <div class="layui-form-item">
            <label class="layui-form-label">父包名<span style="color:red"> *</span></label>
            <div class="layui-input-inline" style="width: 275px">
                <input type="text" value="com.zxdmy.excite" name="parentPack" lay-verify="parentPack"
                       placeholder="请输入手机号码" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">父模块的包名</div>
        </div>
        <!-- 作者 -->
        <div class="layui-form-item">
            <label class="layui-form-label">项目作者<span style="color:red"> *</span></label>
            <div class="layui-input-inline" style="width: 275px">
                <input type="text" value="拾年之璐" name="author" lay-verify="author" placeholder="请输入项目作者"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">项目开发者</div>
        </div>
        <!-- 提交按钮 -->
        <div class="layui-form-item">
            <button class="layui-btn" lay-submit="#" lay-filter="form-table-generator">生成代码</button>
        </div>
    </form>
</div>
<!--引入JS文件-->
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['table'], function () {
        let $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        // 表格
        let star_table = table.render({
            elem: '#table-generator-table',
            url: '/ipoSearch/getUserStar',
            response: {
                statusCode: 200
            },
            height: 'full-55', //高度最大化减去差值
            toolbar: '#toolbar-table-table', //开启头部工具栏，并为其绑定左侧模板
            defaultToolbar: ['filter', 'exports'],
            title: '我的收藏',
            cols: [
                [
                    {type: 'numbers'},
                    // {type: "checkbox", width: 50},
                    {field: 'secCodeStr', title: '股票代码', width: 150, align: '', sort: true},
                    {field: 'title', title: '标题', width: '20%', align: ''},
                    {field: 'digest', title: '摘要', width: '50%', align: ''},
                    {field: 'updateTimeStr', title: '收藏时间', align: ''},
                    {fixed: 'right', title: '操作', align: 'center', toolbar: '#tool-table-table', width: 200}
                ]
            ],
            page: true,
            done: function (res, curr, count) {
                // 此处修复bug：删除最后一页数据后，跳转至上一页
                if (res.data.length === 0 && curr > 1) {
                    star_table.reload({page: {curr: curr - 1}});
                }
                currPage = curr
            }
        });

        // 【行末操作】监听表格行末按钮
        table.on('tool(table-generator-table)', function (obj) {
            let data = obj.data;
            let layEvent = obj.event;
            switch (layEvent) {
                // 【表详情】按钮
                case "table-details":
                    layer.open({
                        type: 1,
                        shade: 0.2,
                        title: '信息详情',
                        skin: 'layui-layer-prompt',
                        shadeClose: true,
                        area: ['900px', '800px'],
                        content: "<div id=\"viewer-container\" style='height: 800px'></div>",
                        success: function (layero, index) {
                            console.log("---------------->" + data.docId);
                            // 数据库表详情
                            $("#viewer-container").html("<iframe src=\"https://weixin.qianlima.com/qlmYFB/pdf/web/viewer.html?file=https%3A%2F%2Fyfb-file.oss-cn-hangzhou.aliyuncs.com%2Findustry_reports%2F20240409%2F1712650317107.pdf%3FExpires%3D4866250320%26OSSAccessKeyId%3DLTAIOb2FQSkCEu7K%26Signature%3DYyX4l099xTc6E9WPmsgimF4ErMI%253D\" width=\"100%\" height=\"100%\" frameborder=\"no\" ,=\"\" border=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" allowtransparency=\"yes\"></iframe>")
                        }
                    });
                    break;
                // 【删除】按钮
                case "table-del":
                    let docId = data.docId;
                    layer.confirm('确认删除 [' + data.secCodeStr + "] 信息吗？", {
                        title: false,
                        btn: ['确认', '取消'],
                        // 按钮【按钮1】的回调
                        btn1: function (index) {
                            $.post("/ipoSearch/delUserStar", {
                                docId: docId
                            }, function (d) {
                                // 根据返回状态码输出提示信息，200 表示成功，其他表示失败
                                if (d.code === 200) {
                                    layer.msg(d.msg, {time: 1000, icon: 1});
                                    star_table.reload()
                                } else {
                                    layer.msg(d.msg, {time: 3000, icon: 2});
                                }
                            });
                        },
                    });
                    break;
            }
        });

    });
</script>
</body>
</html>